﻿@model DingTalkAgent.Web.Models.Patr_Page
@{
    ViewBag.Title = "历史巡河信息";
    Layout = "~/Areas/mobile/Views/Shared/_Layout.cshtml";
}

<style>
    .footer-tab {
        height: 40px;
        position: fixed;
        bottom: 0px;
    }

    .divimg img {
        width: 60px;
        height: 60px;
        margin: 3px;
        display: inline-block;
    }
</style>
<div class="dd-container bt50">
    @Html.Hidden("pageIndex", 1)
    @Html.Hidden("isme")
@if (ViewBag.isme == 0)
{
    <div class="tab-menu dd-menu-bar dd-f">
        <a href="/mobile/patrolLog/list?isme=1" class="dd-menu" ><span>我的</span></a>
        <a href="/mobile/patrolLog/list?isme=0" class="dd-menu  active-tab-menu" ><span>我管辖的</span></a>
        <a href="#" class="dd-menu " ><span>违规</span></a>
    </div>
}
else
{
    <div class="tab-menu dd-menu-bar dd-f">
        <a href="/mobile/patrolLog/list?isme=1" class="dd-menu active-tab-menu"><span>我的</span></a>
        <a href="/mobile/patrolLog/list?isme=0" class="dd-menu "><span>我管辖的</span></a>
        <a href="#" class="dd-menu "><span>违规</span></a>
    </div>
}
    <div class="dd-sub-tab show" id="tabA1">

        <div class="dd-container">

            <div class="dd-box dd-top-line  m-t11 m-b11">

                
                @if (ViewBag.isme == 0)
                {
                    <h4 class="dd-search-bar dd-f dd-tit-bottom-line h50">
                        <span class="dd-item-tit left-line fw">选择查看条件</span>
                        <a href="#" onclick="changeData(this)" style="margin-right:15px;">统计</a>
                    </h4>
                    <div class="dd-search-bar dd-search-item dd-f h50 dd-bottom-line">
                        <span class="dd-item-tit w120">河源类型</span>
                        <div class="dd-item-ft p-r15">
                            <div class="dd-select-out">
                                <span class="dd-select-hide"></span>
                                @Html.DropDownList("riverSourceType", @Model.ListMyRSourceType, new { @class = "dd-item-select" })
                            </div>
                        </div>
                    </div>

                    <div class="dd-search-bar dd-search-item dd-f h50 dd-bottom-line">
                        <span class="dd-item-tit w120">河源段</span>
                        <div class="dd-item-ft p-r15">
                            <div class="dd-select-out">
                                <span class="dd-select-hide"></span>
                                <span id="spanleveCode">@Html.DropDownList("leveCode", Model.ListleveCodeList, new { @class = "dd-item-select" })</span>
                            </div>
                        </div>
                    </div>
                }
                
            </div>

            <div id="list">
                @Html.Partial("List_Partial", Model)
            </div>
            <div id="listStats"></div>
        </div>

    </div>

    <div class="dd-sub-tab hidden" id="tabA2">
        <div class="long-bar ">
            <div class="tab-sub-menu dd-menu-bar-w w600">
                <a href="#" class="dd-sub-menu active-sub-tab-menu" onclick="tabchage2('#tabB1')"><span>明细</span></a>
                <a href="#" class="dd-sub-menu" onclick="tabchage2('#tabB2')"><span>统计模式</span></a>
                <a href="#" class="dd-sub-menu" onclick="tabchage2('#tabB3')"><span>明细1</span></a>
                <a href="#" class="dd-sub-menu" onclick="tabchage2('#tabB4')"><span>统计模式1</span></a>
                <a href="#" class="dd-sub-menu" onclick="tabchage2('#tabB5')"><span>明细2</span></a>
                <a href="#" class="dd-sub-menu" onclick="tabchage2('#tabB6')"><span>统计模式2</span></a>
            </div>
        </div>
        <div class="dd-sub-sub-tab show m-t108" id="tabB1">
            112233
        </div>
        <div class="dd-sub-sub-tab hidden" id="tabB2">
            445566
        </div>
    </div>

    <div class="dd-sub-tab hidden" id="tabA3">
        789
    </div>

</div>

<div class="footer-menu-bar dd-menu-bar dd-top-line">
    <a href="/mobile/patrolLog/index" class="footer-menu "><i class="icon iconfont icon-shuilishehuituanti dd-i-f-hzxh"></i><span>河长巡河</span></a>
    <a href="/mobile/patrolLog/list" class="footer-menu active-footer-tab"><i class="icon iconfont icon-kaoshi1 dd-i-f-lsjl"></i><span class="lsjl-span">历史记录</span></a>
</div>

<script>

</script>
<script>

    $(function () {
        $.post("/mobile/login/init", "url=@ViewBag.url&CorpID=ss", function (_config) {
            dd.config({
                agentId: _config.agentId,
                corpId: _config.corpId,
                timeStamp: _config.timeStamp,
                nonceStr: _config.nonceStr,
                signature: _config.signature,
                jsApiList: ['runtime.info', 'device.notification.prompt', 'biz.chat.pickConversation', 'device.notification.confirm',
           'device.notification.alert',
           'device.notification.prompt',
           'biz.chat.open',
           'biz.util.open', 'device.geolocation.get', 'biz.map.locate', 'biz.map.view', 'biz.map.view', 'biz.util.uploadImageFromCamera',
           'biz.user.get',
           'biz.contact.choose',
           'biz.telephone.call',
           'biz.ding.post']
            });

            //dd.ui.pullToRefresh.disable();
            dd.ready(function () {
                dd.biz.navigation.setTitle({
                    title: '历史巡河信息',
                    onSuccess: function (data) {
                    },
                    onFail: function (err) {
                        log.e(JSON.stringify(err));
                    }
                });
                //	 alert('dd.ready rocks!');

                dd.runtime.info({
                    onSuccess: function (info) {
                        console.log('runtime info: ' + JSON.stringify(info));
                    },
                    onFail: function (err) {
                        console.log('fail: ' + JSON.stringify(err));
                    }
                });
                dd.ui.pullToRefresh.enable({
                    onSuccess: function () {
                        var page = parseInt($("#pageIndex").val()) + 1;
                        $("#pageIndex").val(page)
                        $.ajax({
                            type: "POST",
                            url: "list",
                            data: "pageIndex=" + $("#pageIndex").val() + "&isme=" + $("#isme").val() + "&riverSourceType=" + $("#riverSourceType").val() + "&leveCode=" + $("#leveCode").val(),
                            success: function (msg) {
                                dd.ui.pullToRefresh.stop();
                                $("#list").append(msg);
                            }
                        });
                    },
                    onFail: function () {
                    }
                });

            });



            dd.error(function (err) {
                alert('dd error: ' + JSON.stringify(err));
            });

        })

        $("#riverSourceType").change(function () {
            $.ajax({
                type: "POST",
                url: "getleveCodeList",
                data: "riverSourceType=" + $(this).val(),
                success: function (msg) {
                    $("#spanleveCode").html(msg);
                    $("#leveCode").on("change", function () {
                        $("#pageIndex").val("1");

                        getloadData()

                    });
                    getloadData();

                }
            });

        });
        $("#leveCode").on("change", function () {
            $("#pageIndex").val("1");
            getloadData();
        });



    })

    ///重加载时用
    function getloadData() {
        $.ajax({
            type: "POST",
            url: "list",
            data: "pageIndex=" + $("#pageIndex").val() + "&isme=" + $("#isme").val() + "&riverSourceType=" + $("#riverSourceType").val() + "&leveCode=" + $("#leveCode").val(),
            success: function (msg) {
                //  dd.ui.pullToRefresh.stop();
                $("#list").html(msg);
            }
        });
    }

    function showImage(_div, _src)
    {

        var urls = new Array();
        $(_div).find("img").each(function () {
            urls.push($(this).attr("src"));
        });
        dd.biz.util.previewImage({
            urls: urls,//图片地址列表
            current: _src,//当前显示的图片链接
            onSuccess: function (result) {
                /**/
            },
            onFail: function (err) { }
        })
    }

    ///加载地图
    function loadmap(_longitude,_latitude,_address)
    {
        dd.biz.map.view({
            latitude: _latitude, // 纬度
            longitude: _longitude, // 经度
            title: _address// 地址/POI名称
        });
    }

    //切换明细与统计
    function changeData(_this)
    {
        var t = $(_this).html();
        if (t == "明细")
        {
            $("#listStats").hide();
            $("#list").show();
            $(_this).html("统计");
        }
        else {
            $("#listStats").show();
            $("#list").hide();
            $(_this).html("明细");
            $.ajax({
                type: "POST",
                url: "listStats",
                data: "patrolType=4&leveCode=" + $("#leveCode").val(),
                success: function (msg) {
                    $("#listStats").html(msg);
                }
            });
        }
    }
    
</script>


<script type="text/javascript">
	$(document).ready(function(){
		$("#tab1").show();
		$("#tab2").hide();
		$(".footer-menu").click(function(){
			$(".footer-menu").removeClass("active-footer-tab");
			$(this).addClass("active-footer-tab");
		});
		$(".dd-menu").click(function(){
			$(".dd-menu").removeClass("active-tab-menu");
			$(this).addClass("active-tab-menu");
		});
		$(".dd-sub-menu").click(function(){
			$(".dd-sub-menu").removeClass("active-sub-tab-menu");
			$(this).addClass("active-sub-tab-menu");
		});
	  })
	function tabchage(_id) {
		$(".dd-tab").hide();
		$(_id).show();
	}
	function tabchage1(_id) {
		$(".dd-sub-tab").hide();
		$(_id).show();
	}
	function tabchage2(_id) {
		$(".dd-sub-sub-tab").hide();
		$(_id).show();
	}
</script>
